﻿
function guanzhu(uid,t)
{
	 
	window.open("http://weibo.com/u/"+uid);    
	$(t).css("display","none");
	$("#lq_"+uid).css("display","");
}

function zhuanfa(id,s_id,t,uid)
{
	 
	window.open("http://weibo.com/"+uid+"/"+s_id);    
	$(t).css("display","none");
	$("#repost_"+id).css("display","");
}

var TU = {};
TU.msgbox = {
	Counter: 0,
	open: function(j, l, k, i, f) {
	
		l = typeof l != "undefined" ? l : 1;
		k = typeof k != "undefined" ? k : 2;
		$(".tu_msg_window").remove();
		var h = j.indexOf("<script");
		if (h != -1) {
			j = "正在载入中..." + j
		}
		if ($.browser.msie && $.browser.version == "6.0") {
			$("select").css("visibility", "hidden")
		}
		this.Counter++;
		var g = '<div id="tu_msg_' + this.Counter + '" class="tu_msg_window"><div class="tu_msg_wrap">' + j + "</div></div>";
		$("body").append(g);
		$("#tu_msg_" + this.Counter + " > .tu_msg_wrap").addClass("tu_msg_ico_" + l);
		this.position(this.Counter, i);
		if (typeof f == "function") {
			f()
		}
		if (k != undefined && k != 0) {
			$("#tu_msg_" + this.Counter + " > .tu_msg_wrap").append('<div class="tu_msg_autoclose">(' + k + "秒后关闭)</div>");
			setTimeout('$("#tu_msg_' + this.Counter + '").remove();if($.browser.msie && $.browser.version=="6.0"){$("select").css("visibility", "visible");}', k * 3000)
		}
	},
	position: function(h, g) {
		var d = $("#tu_msg_" + h).width();
		var f = $("#tu_msg_" + h).height();
		$("#tu_msg_" + h).css({
			marginLeft: "-" + parseInt(d / 2) + "px"
		});
		if (typeof g == "undefined") {
			$("#tu_msg_" + h).css({
				marginTop: "-" + (parseInt(f / 2) + 100) + "px"
			})
		} else {
			var e = g - parseInt(f / 2);
			e = e <= 50 ? 50 : e;
			$("#tu_msg_" + h).css("top","300px")
		}
	},
	success: function(b, c, a) {
		a = a || 1;
		this.open(c, 1, a, b)
	},
	alert: function(a, b) {
	 
		this.open(b, 2, 2, a)
	},
	confirm: function(b, a) {
		if (confirm(b)) {
			if ($.isFunction(a)) {
				a()
			}
		}
	}
};


TU.dialog = {
	Counter: 0,
	init: function(f, e) {
		if ($.browser.msie && $.browser.version == "6.0") {
			$("select").css("visibility", "hidden")
		}
		if (e) {
			var d = '<div id="tu_dialog_overlay"></div><div id="tu_dialog_window"><div class="tu_dialog_in_window"><div id="tu_dialog_title"><span class="left">标题</span><a id="tu_dialog_close" href="javascript:;" title="关闭" class="close">&times;</a></div><div id="tu_dialog_body"></div></div></div>'
		} else {
			var d = '<div id="tu_dialog_overlay"></div><div id="tu_dialog_loading"></div><div id="tu_dialog_window"><div class="tu_dialog_in_window"><div id="tu_dialog_title"><span class="left">标题</span><a id="tu_dialog_close" href="javascript:;" title="关闭" class="close">&times;</a></div><div id="tu_dialog_body"></div></div></div>'
		}
		$("body").append(d);
		var c = this.closeFun ? this.closeFun : function() {};
		$("#tu_dialog_close").click(function() {
			c();
			TU.dialog.close();
			return false
		});
		$("#tu_dialog_overlay").show();
		$("#tu_dialog_loading").show();
		this.position(f);
		return this
	},
	openHtml: function(g, k, h, l, j, m, i) {
		if (i && $.isFunction(i.closeFun)) {
			this.closeFun = i.closeFun
		}
		this.init(j);
		if (g != undefined) {
			if (typeof g == "object") {
				$("#tu_dialog_body").append(g.children());
				this.close_fun2 = function() {
					g.append($("#tu_dialog_body").children())
				}
			} else {
				$("#tu_dialog_body").html(g)
			}
		}
		this.title(k == undefined ? "标题" : k);
		this.resize(h ? h : 300, l ? l : 150, j);
		$("#tu_dialog_loading").remove();
		$("#tu_dialog_window").show();
		if ($.isFunction(m)) {
			m()
		}
		return this
	},
	openUrl: function(m, i, o, k, h) {
		this.init(true);
		var n = o != undefined ? o : 300;
		var j = k != undefined ? k : 150;
		var p = h != undefined ? h : "no";
		var l = (new Date).getTime();
		if (m.indexOf("?") == -1) {
			m = m + "?_t=" + l
		} else {
			m = m + "&_t=" + l
		}
		this.title(i == undefined ? "标题" : i);
		$("#tu_dialog_body").html('<iframe id="tu_dialog_iframe" scrolling="' + p + '" frameborder="0"></iframe>');
		$("#tu_dialog_iframe").attr("src", m);
		this.resize(n, j);
		$("#tu_dialog_loading").remove();
		$("#tu_dialog_window").show()
	},
	close: function() {
		if (typeof this.close_fun2 == "function") {
			this.close_fun2()
		}
		$("#tu_dialog_window").fadeOut(200, function() {
			$(this).remove()
		});
		$("#tu_dialog_overlay").remove();
		if ($.browser.msie && $.browser.version == "6.0") {
			$("select").css("visibility", "visible")
		}
		return this
	},
	resize: function(f, i, g) {
		var h = f ? f : 300;
		var e = i ? i : 150;
		$("#tu_dialog_window").css({
			width: h + "px",
			height: e + "px"
		});
		$("#tu_dialog_body").css("height", "99%").css("height", i - 48 + "px");
		this.position(g);
		return this
	},
	position: function(d) {
		var b = $("#tu_dialog_window").width();
		var c = $("#tu_dialog_window").height();
		$("#tu_dialog_window").css("left", ($(window).width() - b) / 2);
		if (typeof d == "undefined") {
			if ($.browser.msie && $.browser.version == "6.0") {
				$("#tu_dialog_window").css("top", $(window).scrollTop() + ($(window).height() - c) / 2)
			} else {
				$("#tu_dialog_window").css({
					marginTop: "-" + parseInt(c / 2) + "px"
				})
			}
		} else {
			var a = d - parseInt(c / 2);
			a = a <= 50 ? 50 : a;
			$("#tu_dialog_window").css("top", a + "px")
		}
		return this
	},
	title: function(b) {
		if (b != undefined) {
			$("#tu_dialog_title span").text(b);
			return this
		} else {
			return $("#tu_dialog_title span").text()
		}
	},
	openWeibo: function(b) {
		var a = ["<div id='weibos'>", "</div>"].join("");
		this.openHtml($("<div/>").html(a), "从最近50条微博中选择自己的微博(最多可选5条)", 700, 420, b);
		TU.loading($("#weibos"));
		$.get("../welcome/getweibo", function(c) {
			TU.remove_loading($("#weibos"));
			if (c.status == 1) {
				$("#weibos").html(c.data);
				$("#weibos").find("div.weibo").click(function() {
					if($(this).find("input[type=checkbox]").attr("checked")==undefined)
                    {
                        $(this).find("input[type=checkbox]").attr("checked", false);
                    }else{
                       $(this).find("input[type=checkbox]").attr("checked", true);
                    }
                    
				});
				$("#weibos").find("a.btn").click(function() {
					//var d = $("#weibos").find("input[type=checkbox][checked]").val();
                    var d = '';
                    var w = 0
                   $("input[type=checkbox][checked]").each(function(){
                        w++;
                        if(d == ''){
                            d =$(this).val();
                        }else{
                            d = d+','+$(this).val();
                        }
                    });
                    if(d == '')
                    {
                        TU.msgbox.alert(b,'至少选择一条微博');
                        return false;
                    }else if(w > 5){
                        TU.msgbox.alert(b,'一次最多选择5条微博');
                        return false;
                    }
					//var e = $("#weibos").find("input[type=radio]:checked").next("div").find("p.text").text();
				//	e = e.substring(0, 15) + "...";
					$("#repost_content_id").val(d);
					$("#repost_content_btn").replaceWith("<span id='repost_status_text'>已经选择微博</span>");
					TU.dialog.close()
				})
			} else {
				TU.msgbox.alert(b, c.info)
			}
		}, "json")
	}
};


TU.loading = function(a) {
	var b = $('<div class="tu_loading" style="text-align:center;padding: 2px 0;"><img src="/img/loading.gif" /></div>');
	if (a.find("div.tu_loading").length == 0) {
		a.append(b)
	}
};
TU.remove_loading = function(a) {
	a.find("div.tu_loading").hide().remove()
};
var FAN_POINT_SCALA = 1000;
function tu_tfollows(a,b){

    if(a){
        $.post("../welcome/dofollow",
        {sid:a},
        function(c){
		
            if(c.status==1)
            {
			
                TU.msgbox.success(0,c.info);
                gettfollow(1);
                }else{
  
                TU.msgbox.alert(0,c.info);
                if(c.info == '已经关注此用户')
                    {
                	gettfollow(1);
                    }
            }
        },"json")
    }
    return false
}	

$(function() {
	
	gettfollow(1);
	$("#signin_btn").popover();
		
		$("#signin_btn").click(function() {
		var c = $(this);
		c.button("loading");
		$.get("../welcome/signin", function(d) {
			if (d.status == 1) {
				TU.msgbox.success(c.offset().top, d.info);
				c.button("complete");
				c.unbind("click");
				c.popover("hide");
				/*
				var e = ["<div style='padding:0 10px 5px;'>", "<textarea style='width:430px; height:70px;' id='signpostcontent'>#爱互粉#我今天在@爱互粉网 签到获得了" + d.data + "积分，运气还不错哦，你也快来试试吧！http://www.aihufen.com/?invite=" + cl_id + "</textarea>", "<p class='mt10'><a class='btn btn-primary' id='signpostbtn'>分享到微博</a>&nbsp;&nbsp;<span style='color:#999;'>(签到后分享加送10分，说不定还有意外惊喜哦)</span></p>", "</div>"].join("");
				TU.dialog.openHtml($("<div/>").html(e), "签到成功，分享一下吧", 450, 170, 200);
				$("#signpostbtn").on("click", function() {
				 
					var f = $.trim($("#signpostcontent").val());
					$.post("../welcome/dopost", {
						content: f,
						action: "signin"
					}, function(g) {
						if (g.status == 1) {
							TU.msgbox.success($("#signpostbtn").offset().top, g.data, 2);
							TU.dialog.close()
						} else {
							if (g.status == 2) {
								TU.msgbox.success($("#signpostbtn").offset().top,  g.data , 3);
								TU.dialog.close()
							} else {
								TU.msgbox.alert($("#signpostbtn").offset().top, g.info)
							}
						}
					}, "json")
				})*/
			} else {
				TU.msgbox.alert(c.offset().top, d.info)
			}
		}, "json")
	});
		
		
		
	function gettfollow()
	{
	
		$("#tfollows").empty();
	    TU.loading($("#tfollows"));
	     
	    $.get("../welcome/tfollowtuis/1/0/0",
	              function(i){
	                TU.remove_loading($("#tfollows"));
	                if(i.status==1){
	                    $("#tfollows").html(i.data.body);
	                    
	                }else{
	                   TU.msgbox.alert($("#tfollows").offset().top,i.info)
	                }
	            },"json")
	}
	
	
	var b = ["<div>", '<p style="margin-bottom:10px;">如果已经设置过关注，请去<a href="../welcome/mytg">我的推广</a>修改</p>', '<span class="fbold">出分：</span><input value="10" id="follow_points" class="span1" type="text" placeholder="请输入整数，至少3分" style="padding:2px;" maxlength="3"/>', '<p>输入整数个积分，至少<b style="color:red;">3</b>分，最多99分，代表别人每关注你一次，别人会获得该积分，而你会失去这么多分。</p>', '<div class="mt10">', '<span class="fbold">性别限制：</span><select class="follow_select" id="follow_gender"><option value="0">不限</option><option value="1">女</option><option value="2">男</option></select>', "<p>(限制什么性别的用户可以关注你)</p>", "</div>", '<div class="mt10">', '<span class="fbold">粉丝数限制：</span><input value="0" id="follow_fans" class="span1" type="text" style="padding:2px; width:130px;" maxlength="6"/>', "<p>(限制他人的粉丝数必须大于设置值才可以关注你，为“0”表示不限制)</p>", "</div>", '<div class="mt10">', '<span class="fbold">最大次数：</span><input value="0" id="follow_max_num" class="span1" type="text" style="padding:2px; width:145px;" maxlength="4"/>', "<p>(最多被允许关注的次数，可以有效的防止积分过度消耗，设置为“0”则不限制)</p>", "</div>", '<a id="dofollow_btn" class="btn btn-primary mt10">确定</a>', "</div>"];
	$("#follow_btn").popover({
		trigger: "manual",
		placement: 'leftbottom',
		title: '<span class="left">求粉丝设置</span> <a href="javascript:;" class="close" onclick="$(\'#follow_btn\').popover(\'hide\');">&times;</a>',
		content: b.join("")
	});
	$("#follow_btn").click(function() {
		$(this).popover("toggle");
		$("#dofollow_btn").unbind("click").click(function() {
			var c = $(this);
			var h = $.trim($("#follow_points").val());
			var g = $.trim($("#follow_max_num").val());
			var f = $("#follow_gender").val();
			var d = $.trim($("#follow_fans").val());
			var e = /^\d{1,2}$/;
			if (!e.test(h)) {
				TU.msgbox.alert(c.offset().top, "出分最多99分");
				return false
			}
			if (parseInt(h) <= 2) {
				TU.msgbox.alert(c.offset().top, "出分至少设置3分");
				return false
			}
			e = /^\d{1,4}$/;
			if (!e.test(g)) {
				TU.msgbox.alert(c.offset().top, "最大次数请输入一到四位数字");
				return false
			}
			e = /^\d{1,6}$/;
			if (!e.test(d)) {
				TU.msgbox.alert(c.offset().top, "限制粉丝数请输入一到六位数字");
				return false
			}
			if (d > h * FAN_POINT_SCALA) {
				TU.msgbox.alert(c.offset().top, "限制粉丝数不能大于设置出分的" + FAN_POINT_SCALA + "倍，您最大可设置的粉丝数为" + h * FAN_POINT_SCALA);
				return false
			}
			$.get("../welcome/addfollowtask/" + h + "/" + g + "/" + f + "/" + d, function(i) {
				if (i.status == 1) {
					TU.msgbox.success(c.offset().top, "设置成功");
					$("#follow_btn").popover("hide")
				} else {
					TU.msgbox.alert(c.offset().top, i.info)
				}
			}, "json")
		})
	});
	var a = ["<div>", '<p style="margin-bottom:10px;">可以去<a href="../welcome/mytg">我的推广</a>编辑删除转发</p>', '<span class="fbold">出分：</span><input value="10" id="repost_points" class="span1" type="text" placeholder="请输入整数，至少3分" style="padding:2px;" maxlength="3"/>分越高转的越多', '<p>(整数，至少<b style="color:red;">3</b>分，最多99分，代表别人转发一次会获得该积分，而你会失去几分)</p>',  '<div class="mt10">', '性别限制：<select class="follow_select" id="repost_gender"><option value="0">不限</option><option value="1">女</option><option value="2">男</option></select>', "<p>(限制什么性别的用户可以转发)</p>", "</div>",'<div class="mt10">', '<span class="fbold">粉丝数限制：</span><input value="0" id="repost_fans" class="span1" type="text" style="padding:2px; width:130px;" maxlength="6"/>', "<p>(限制他人的粉丝数必须大于设置值才能转发，为“0”表示不限制)</p>", "</div>", '<div class="mt10">', '<span class="fbold">最大次数：</span><input value="0" id="repost_max_num" class="span1" type="text" style="padding:2px; width:145px;" maxlength="4"/>', "<p>(该微博最多被允许转发的次数，可以有效的防止积分过度消耗，设置为0则不限制)</p>", "</div>", '<div class="mt10">', '<input type="hidden" id="repost_content_id" value=""/>', '<span class="fbold">内容：</span><a id="repost_content_btn" class="btn">从我的微博中选择</a>', "<p>(粉丝数不足300，则只显示自己的原创微博)</p>", "</div>", "</div>",'<div class="mt10">','<span class="fbold"><font style="color:red;">*</font>预设置转发理由：</span>','<a id="repost_reason_btn" class="btn">设置</a>',"<p>(转发该微博时默认显示预设置的转发理由)</p>",'<div id="reasons_text2" class="hide"></div>',"</div>", '<a id="dorepost_btn" class="btn btn-primary mt10">确定</a>'];
	$("#repost_btn").popover({
		trigger: "manual",
		placement: 'leftbottom',
		title: '<span class="left">求转发设置</span> <a href="javascript:;" class="close" onclick="$(\'#repost_btn\').popover(\'hide\');">&times;</a>',
		content: a.join("")
	});
	$("#repost_btn").click(function() {
		$(this).popover("toggle");
		$("#repost_content_btn").click(function() {
			TU.dialog.openWeibo($(this).offset().top - 160)
			//选择微博框位置
		});

		$("#repost_reason_btn").click(function() {
			var c = ["<div id='set_reasons' style='padding:10px;'>", "<p>请设置合理的转发理由，不能包含链接，只能@当前账号，最多140个字。最多可设置20条。</p>", "<p>别人转发该微博时会默认随机显示你预设置的转发理由。（仅爱护粉会员可用）</p>", "<p><a class='btn btn-primary' id='add_reason'>添加一条</a></p>", "<div id='reasons_text' style='padding:10px 0; height:360px; overflow-y:auto;'>", "</div>", "<div class='mt10'>", "<a class='btn btn-primary' id='save_reason'>保存</a>", "</div>", "</div>"].join("");
			TU.dialog.openHtml($("<div/>").html(c), "预设置转发理由", 600, 550, $(this).offset().top - 40);
			if ($("#reasons_text2").html() != "") {
				$("#reasons_text").html($("#reasons_text2").html())
			}
			$("#add_reason").unbind("click").click(function() {
				//if (!is_vip) {
				//	TU.msgbox.alert($(this).offset().top, "对不起，仅会员可用，请先开通会员");
				//	return false
				//}
				if ($("#reasons_text p").length >= 20) {
					TU.msgbox.alert($(this).offset().top, "最多只能设置20条");
					return false
				}
				$("#reasons_text").append("<p style='margin-top:10px;'><textarea style='width:480px;height:50px;'></textarea>&nbsp;&nbsp;&nbsp;&nbsp;<a class='btn btn-primary' onclick='$(this).parent().remove();'>删除</a></p>");
				$("#reasons_text p textarea").unbind("blur").blur(function() {
					var f = $.trim($(this).val());
					if (f.length > 140) {
						TU.msgbox.alert($(this).offset().top, "转发理由最多140个字");
						return false
					}
					var e = /http:\/\//;
					if (e.test(f)) {
						TU.msgbox.alert($(this).offset().top, "转发理由不能包含链接");
						return false
					}
					var d = (f.split("@")).length - 1;
					if (d != 0) {
						if (d > 1 || (d == 1 && !new RegExp("@" + nickname).test(f))) {
							TU.msgbox.alert($(this).offset().top, "转发理由只能@当前账号");
							return false
						}
					}
				})
			});
			$("#save_reason").unbind("click").click(function() {
				var d = false;
				$("#reasons_text textarea").each(function() {
					var g = $.trim($(this).val());
					if (g == "") {
						TU.msgbox.alert($(this).offset().top, "转发理由不能为空");
						d = true;
						return false
					}
					if (g.length > 140) {
						TU.msgbox.alert($(this).offset().top, "转发理由最多140个字");
						d = true;
						return false
					}
					var f = /http:\/\//;
					if (f.test(g)) {
						TU.msgbox.alert($(this).offset().top, "转发理由不能包含链接");
						d = true;
						return false
					}
					var e = (g.split("@")).length - 1;
					if (e != 0) {
						if (e > 1 || (e == 1 && !new RegExp("@" + nickname).test(g))) {
							TU.msgbox.alert($(this).offset().top, "转发理由只能@当前账号");
							d = true;
							return false
						}
					}
					$(this).text(g)
				});
				if (d == false) {
					$("#reasons_text2").html($("#reasons_text").html());
					TU.dialog.close()
				}
			})
		});

		$("#dorepost_btn").unbind("click").click(function() {
			var c = $(this);
			var g = $.trim($("#repost_points").val());
			var e = $("#repost_content_id").val();
			var h = $.trim($("#repost_status_text").text());
			var i = $.trim($("#repost_max_num").val());
			var d = $.trim($("#repost_fans").val());
			var reasons = [];
			var increment= 0;
			$("#reasons_text2 textarea").each(function() {
				reasons[increment] = $(this).val();
				increment++;
			})
            var l = $("#repost_gender").val();
			var f = /^\d{1,2}$/;
			if (!f.test(g)) {
				TU.msgbox.alert(c.offset().top, "出分最多99分");
				return false
			}
			if (parseInt(g) <= 2) {
				TU.msgbox.alert(c.offset().top, "出分至少设置3分");
				return false
			}
			if (!e) {
				TU.msgbox.alert(c.offset().top, "请选择一条微博");
				return false
			}
			f = /^\d{1,4}$/;
			if (!f.test(i)) {
				TU.msgbox.alert(c.offset().top, "最大次数请输入一到四位数字");
				return false
			}
			f = /^\d{1,6}$/;
			if (!f.test(d)) {
				TU.msgbox.alert(c.offset().top, "限制粉丝数请输入一到六位数字");
				return false
			}
			if (d > g * FAN_POINT_SCALA) {
				TU.msgbox.alert(c.offset().top, "限制粉丝数不能大于设置出分的" + FAN_POINT_SCALA + "倍，您最大可设置的粉丝数为" + g * FAN_POINT_SCALA);
				return false
			}
			$.post("../welcome/addreposttask", {
				point: g,
				status_id: e,
				content: h,
				max_num: i,
                			repost_gender: l,
                			"reasons[]": reasons,
				fans: d
			}, function(j) {
				if (j.status == 1) {
					TU.msgbox.success(c.offset().top, "设置成功");
					$("#repost_btn").popover("hide")
				} else {
					TU.msgbox.alert(c.offset().top, j.info)
				}
			}, "json")
		})
	});

	$("#how_to_coins").popover({
		trigger: "manual",
		title: '<span class="left">如何获得粉币</span> <a href="javascript:;" class="close" onclick="$(\'#how_to_coins\').popover(\'hide\');">&times;</a>',
		content: '<p style="margin-bottom:10px;">任务1：每日完成签到，自动奖励+5粉币 <br/>任务2：每日完成邀请分享，自动奖励+5粉币  <br/>任务3：每关注一个，自动奖励+1粉币 <br/> 任务4：每转发一个，自动奖励+1粉币 <br/> 任务5：邀请1个好友，自动奖励+10粉币</p></div>'
	});
	$("#how_to_coins").mouseover(function() {
		var c = $(this);
		c.popover("toggle");
	});
	$("#how_to_coins").mouseleave(function() {
		var c = $(this);
		c.popover("hide");
	});
	
	$("#invite_btn").popover({
		trigger: "manual",
		title: '<span class="left">邀请好友</span> <a href="javascript:;" class="close" onclick="$(\'#invite_btn\').popover(\'hide\');">&times;</a>',
		content: '<p style="margin-bottom:10px;">1，复制下面链接发给你的朋友吧，成功邀请一个可获得' + shardf + '积分</p><p class="fbold">http://www.aihufen.com/?invite=' + cl_id + '</p> <div><p style="margin:10px 0;" class="fbold">2，或者也可以分享到微博（最多140个字）</p><p><textarea id="share_text" style="width:310px;height:80px;">我刚用#爱互粉#应用增加了很多真实的活跃粉丝，微博也有人转了，玩微博更带劲了， 你也想增加你的微博影响力吗？ 快来试试吧！http://www.aihufen.com/?invite=' + cl_id + '</textarea></p><a id="share_btn" class="btn btn-primary mt10">分享到我的微博</a> 每6个小时可以点击一次</div>'
	});
	 
	$("#invite_btn").click(function() {
		var c = $(this);
		c.popover("toggle");
		WB2.anyWhere(function(d) {
			d.widget.selector({
				id: "bbcc",
				limit: 5,
				title: "选择几个你想要邀请的好友吧",
				callback: function(g) {
					var f = g.length;
					for (var e = 0; e < f; e++) {
						$("#share_text").prepend("@" + g[e].screen_name + " ")
					}
				}
			})
		});
		$("#share_btn").click(function() {
			var d = $("#share_text").val();
			d = $.trim(d);
			 
			$.post("../welcome/dopost", {
				content: d,
				action:"invite"					
			}, function(e) {
				if (e.status == 1) {
					TU.msgbox.success(c.offset().top,  e.data , 2);
					c.popover("hide")
				} else {
					TU.msgbox.alert(c.offset().top, e.info)
				}
			}, "json")
		})
	});
    var strprice = '支付功能关闭';
	$.get("../pay/getprice", function(i) {
		if (i.status == 1) {
			strprice = i.data;
		}
       $("#buy_btn").popover({
		trigger: "manual",
		title: '<span class="left">购买积分</span> <a href="javascript:;" class="close" onclick="$(\'#buy_btn\').popover(\'hide\');">&times;</a>',
		content: '<div>支持多种购买方式，可淘宝交易，更安全！<form id="payform" action="/pay/alipayto" method="post" target="_blank"><div class="clearfix">' + strprice + '</div><div><a href="javascript:;" onclick="$(\'#payform\').submit();" class="alipay_btn"></a><br><p>在线客服：<a href="http://wpa.qq.com/msgrd?v=3&amp;uin=583028985&amp;site=qq&amp;menu=yes" target="_blank"><img border="0" title="点击这里给我发消息" alt="点击这里给我发消息" src="http://wpa.qq.com/pa?p=2:583028985:42" style="vertical-align:middle"></a></p>支付宝担保交易，安全有保障，付款后在顶部推荐。</div></form></div>'
	});
	}, "json");
	
	$("#buy_btn").click(function() {
		$(this).popover("toggle")
	});
	 


	$("#give_points_btn").popover({
        trigger: "manual",
        title: '<span class="left">积分转让</span> <a id="give_points_btn_close" href="javascript:;" class="close">&times;</a>',
        content: '<div><p>每天只能转让一次，最多只能转让2000分，由爱互粉收取10%的手续费 。</p><p class="mt10"><span class="fbold">对方微博昵称：</span><input type="text" id="give_points_nickname"/></p><p class="mt10"><span class="fbold">转让分数：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input type="text" id="give_points_val" /></p><p class="mt10"><a id="do_give_points" href="javascript:;" class="btn btn-primary">确定</a></p></div>'
    });
    $("#give_points_btn").click(function () {
        $(this).popover("toggle");
        $("#give_points_btn_close").click(function () {
            $("#give_points_btn").popover("hide");
        });
        $("#do_give_points").click(function () {
            var g = $(this);
             
            var i = $.trim($("#give_points_nickname").val());
            var j = $.trim($("#give_points_val").val());
            if(i.length == 0) {
                TU.msgbox.alert($(this).offset().top - 40, "对方微博昵称不能为空");
                return false;
            }
            var h = /^\d{1,4}$/;
            if(j.length == 0) {
                TU.msgbox.alert($(this).offset().top - 40, "转让分数不能为空");
                return false;
            }
            if(!h.test(j)) {
                TU.msgbox.alert($(this).offset().top - 40, "转让分数只能是一到四位数字");
                return false;
            }
            if(parseInt(j) == 0) {
                TU.msgbox.alert($(this).offset().top - 40, "转让分数不能为0");
                return false;
            }
            if(parseInt(j) > 5000) {
                TU.msgbox.alert($(this).offset().top - 40, "转让分数不能大于5000分");
                return false;
            }
            if(confirm("确定要转让积分吗？")) {
                $.post("../welcome/givepoints", {
                    nickname: i,
                    points: j
                }, function (k) {
                    if(k.status == 1) {
                        TU.msgbox.success(g.offset().top - 40, "转让成功");
                        $("#give_points_btn").popover("hide");
                    } else {
                        TU.msgbox.alert(g.offset().top - 40, k.info);
                    }
                }, "json");
            }
        });
    });

 $("#c_list a.btn[id^=exchange_btn_]").click(function() {
        var a = $(this);
        var id = a.attr("id").replace("exchange_btn_", "");
            
         
            if(confirm("确定要转让积分吗？")) {
                $.post("../welcome/exchangegoods", {
                   goodsid:id                
                }, function (k) {
                    if(k.status == 1) {
                        TU.msgbox.success(a.offset().top - 40, "兑换成功");                      
                    } else {
                        TU.msgbox.alert(a.offset().top - 40, k.info);
                    }
                }, "json");
            }
        });







	if ($.browser.msie && parseInt($.browser.version, 10) === 6) {
		$('.row div[class^="span"]:last-child').addClass("last-child");
		$(':button[class="btn"], :reset[class="btn"], :submit[class="btn"], input[type="button"]').addClass("button-reset");
		$(":checkbox").addClass("input-checkbox");
		$('[class^="icon-"], [class*=" icon-"]').addClass("icon-sprite");
		$(".pagination li:first-child a").addClass("pagination-first-child");
		$('input[type="radio"]').css({
			width: "auto",
			height: "auto",
			padding: 0,
			margin: "3px 0",
			"margin-top": 0,
			"line-height": "normal",
			cursor: "pointer",
			border: 0
		})
	}
});






















